﻿<Window x:Class="Shiny.SmartTravel.ConsoleWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:Shiny.SmartTravel.Data.Local;assembly=SmartTravel.Data.Local"
    Title="SmartTravel Console" Height="350" Width="600"
    WindowStartupLocation="CenterScreen" WindowState="Maximized" WindowStyle="None"
    PreviewKeyDown="OnPreviewKeyDown"
    >
    <Window.Background>
        <SolidColorBrush Color="Black" />
    </Window.Background>

    <Window.Resources>
        <ObjectDataProvider x:Name="ProvincesODP" x:Key="Provinces" ObjectType="{x:Type local:ProvincesCollection}" />
    </Window.Resources>
    
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition Width="20" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="20" />
            <RowDefinition />
        </Grid.RowDefinitions>
        
        <!-- Top Menu -->
        <Menu Style="{StaticResource TopMenuStyle}" Grid.ColumnSpan="2">
            <MenuItem Header="_File" Style="{StaticResource TopMenuItemStyle}">
                <MenuItem Name="mFileAccount" Header="My _Account..." Click="mFileAccount_Click" ToolTip="My account settings." />
                <MenuItem Name="mFileMyTravel" Header="_My Travel" ToolTip="Manage my travel" />
                <Separator />
                <MenuItem Name="mFileExit" Header="E_xit" Click="mFileExit_Click" ToolTip="Exit SmartTravel" />
            </MenuItem>
            <MenuItem Header="_Tools" Style="{StaticResource TopMenuItemStyle}">
                <MenuItem Header="Local Data _Updater..." ToolTip="Update local data." />
                <Separator />
                <MenuItem Header="_Options..." ToolTip="Changes the app options" />
            </MenuItem>
            <MenuItem Header="_Help" Style="{StaticResource TopMenuItemStyle}">
                <MenuItem Name="mHelpContent" Header="_Content..." Click="mHelpContent_Click" ToolTip="For detail help content" />
                <MenuItem Name="mHelpAbout" Header="_About..." Click="mHelpAbout_Click" ToolTip="Reading the about SmartTravel" />
            </MenuItem>
        </Menu>
        <!-- Close button -->
        <Button Name="btnTopClose" Grid.Row="0" Grid.Column="1" Style="{StaticResource TopCloseButtonStyle}" Content="X" Click="btnTopClose_Click" ToolTip="Exit SmartTravel" />

        <!-- Content Frame -->
        <Frame Name="ContentFrame" Grid.Row="1" Grid.ColumnSpan="2" Grid.Column="0" />
        
        <!-- Flyouts -->
        <TabControl Style="{StaticResource ControlPanelTabControlStyle}" Name="ControlPanel" MaxHeight="550" MouseLeave="ControlPanel_MouseLeave">
            <TabControl.RenderTransform>
                <TranslateTransform x:Name="ControlPanelTransform" X="0" Y="0" />
            </TabControl.RenderTransform>
            <TabControl.Triggers>

                <EventTrigger RoutedEvent="TabControl.Loaded">
                    <EventTrigger.Actions>
                        <BeginStoryboard>
                            <Storyboard Completed="ControlPanel_Closed">
                                <DoubleAnimation
                    Storyboard.TargetName="ControlPanelTransform"
                    Storyboard.TargetProperty="X"
                    To="-425"
                    Duration="0:0:0.5"
                    BeginTime="0:0:10" />
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger.Actions>
                </EventTrigger>

                <EventTrigger RoutedEvent="TabControl.MouseEnter">
                    <EventTrigger.Actions>
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimation
                    Storyboard.TargetName="ControlPanelTransform"
                    Storyboard.TargetProperty="X"
                    To="0"
                    Duration="0:0:0.5" />
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger.Actions>
                </EventTrigger>

                <EventTrigger RoutedEvent="TabControl.MouseLeave">
                    <EventTrigger.Actions>
                        <BeginStoryboard>
                            <Storyboard Completed="ControlPanel_Closed">
                                <DoubleAnimation
                    Storyboard.TargetName="ControlPanelTransform"
                    Storyboard.TargetProperty="X"
                    To="-425"
                    Duration="0:0:0.5"
                    BeginTime="0:0:0.5" />
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger.Actions>
                </EventTrigger>

            </TabControl.Triggers>

            <!-- if Tag = True, MinWidth of the item is 0 -->
            <TabItem Style="{StaticResource ControlPanelTabItemStyle}" Tag="True" Header="?">
                <Border MaxHeight="450">
                </Border>
            </TabItem>

            <TabItem Style="{StaticResource ControlPanelTabItemStyle}" Tag="False" Header="Help">
                <Border MaxHeight="450">
                </Border>
            </TabItem>

            <TabItem Style="{StaticResource ControlPanelTabItemStyle}" Tag="False" Header="View">
                <StackPanel>
                    <StackPanel.Resources>

                        <DataTemplate x:Key="ViewItemTemplate" DataType="{x:Type local:ProvincesCollection}">
                            <Grid Width="150">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="150" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>

                                <Border Name="OuterBorder"
                          Grid.Row="0"
                          BorderBrush="#414141"
                          BorderThickness="2"
                          Background="{DynamicResource ApplicationBG}"
                          HorizontalAlignment="Stretch"
                          VerticalAlignment="Stretch">
                                </Border>
                                <Border Grid.Row="1" CornerRadius="6" Margin="0 5 0 0" Background="{DynamicResource BlockGrayToBlackBrush}">
                                    <TextBlock Text="{Binding}" FontSize="17" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0 3 0 3" />
                                </Border>
                            </Grid>

                            <DataTemplate.Triggers>
                                <DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsSelected}" Value="True">
                                    <Setter Property="BorderBrush" Value="#27A4CD" TargetName="OuterBorder"/>
                                </DataTrigger>
                            </DataTemplate.Triggers>

                        </DataTemplate>

                        <Style x:Key="ViewListContainerStyle" TargetType="{x:Type ListBoxItem}">
                            <Setter Property="HorizontalContentAlignment" Value="Left" />
                            <!--<Setter Property="Margin" Value="10 0 10 5" />-->
                            <Setter Property="FocusVisualStyle" Value="{x:Null}" />
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="{x:Type ListBoxItem}">
                                        <ContentPresenter />
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>

                        <Style x:Key="ViewListBoxStyle" TargetType="{x:Type ListBox}">
                            <Setter Property="IsSynchronizedWithCurrentItem" Value="True" />
                            <Setter Property="ItemContainerStyle" Value="{StaticResource ViewListContainerStyle}" />
                            <Setter Property="ItemTemplate" Value="{StaticResource ViewItemTemplate}" />
                            <Setter Property="Background" Value="Black" />
                            <Setter Property="BorderThickness" Value="0" />
                            <!-- Set this attached property to 'Disabled' so that the ScrollViewer in the ListBox
                will never show a horizontal scrollbar, and the WrapPanel it contains will be
                constrained to the width of the ScrollViewer's viewable surface. -->
                            <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" />
                            <!-- change itemspanel to WrapPanel -->
                            <Setter Property="ItemsPanel">
                                <Setter.Value>
                                    <ItemsPanelTemplate>
                                        <UniformGrid Columns="2" />
                                    </ItemsPanelTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>

                    </StackPanel.Resources>

                    <TextBlock Text="Change View" FontSize="28" Margin="0,0,0,35" />

                    <ListBox Style="{StaticResource ViewListBoxStyle}"
                     Name="ViewsList"
                     ItemsSource="{Binding Views.View}" />

                </StackPanel>
            </TabItem>

            <TabItem Style="{StaticResource ControlPanelTabItemStyle}" Tag="False" Header="Sort" Name="SortTab">
                <StackPanel>
                    <TextBlock Text="Sorting Feeds" FontSize="28" Margin="0,0,0,35" />

                    <GroupBox Header="Sort feeds in alphabetical order:" Padding="10,20,0,40">
                        <StackPanel HorizontalAlignment="Left">
                            <ToggleButton Style="{DynamicResource SortButtonStyle}"
                              Name="SortByName"
                              Width="200"
                              IsChecked="True"
                              />
                        </StackPanel>
                    </GroupBox>

                    <GroupBox Header="Sort feeds by number of unread items:" Padding="10,20,0,40">
                        <StackPanel HorizontalAlignment="Left">
                            <ToggleButton
                  Style="{DynamicResource SortButtonStyle}" 
                  Name="SortByItemCount" 
                  Width="200" 
                  />
                        </StackPanel>
                    </GroupBox>
                </StackPanel>
            </TabItem>

        </TabControl>

    </Grid>
</Window>
